package cn.zglbk.network.param;

import cn.zglbk.network.context.GatewayMessageContext;

import java.lang.reflect.Method;
import java.lang.reflect.Parameter;

/**
 * @author zglbk.cn
 * @email 1030681978@qq.com
 * @date 2020/10/23 19:09
 */
public class DispatcherMapping {
    /**处理消息的目标对象*/
    private Object targetObj;
    /**处理消息的目标方法*/
    private Method targetMethod;
    private Class<?> param;
    public DispatcherMapping(Object targetObj, Method targetMethod) {
        super();
        this.targetObj = targetObj;
        this.targetMethod = targetMethod;
        Parameter[] parameters = targetMethod.getParameters();
        if(parameters.length > 0){
            if(!parameters[0].getType().isAssignableFrom(GatewayMessageContext.class)){
                this.param = targetMethod.getParameterTypes()[0];
            }
        }

    }
    public Object getTargetObj() {
        return targetObj;
    }
    public Method getTargetMethod() {
        return targetMethod;
    }

    public Class<?> getParam() {
        return param;
    }
}
